package com.haredot.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.haredot.serializer.LocalDateTimeDeserializer;
import com.haredot.serializer.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 
 * @TableName tb_message
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName(value ="tb_message")
public class Message implements Serializable {
    @Serial
    private static final long serialVersionUID = -3922049525230754678L;
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 发送消息的用户ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long fromUser;

    /**
     * 收消息的用户ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long toUser;

    /**
     * 消息内容
     */
    private String content;

    /**
     * 是否已读
     */
    private boolean nread;
    /**
     * 录入时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

}